import CryptoJS from "crypto-js";

const ElckerEryptoStr = "sjwcjifdherg";

// data  必须是字符串
export function ElckerEncrypt(data: any) {
    if (typeof data === 'object') {
        return CryptoJS.AES.encrypt(JSON.stringify(data), ElckerEryptoStr).toString();
    }
    return CryptoJS.AES.encrypt(data, ElckerEryptoStr).toString();
}

export function ElckerDecrypt(ciphertext: any) {
    if (ciphertext) {
        const bytes = CryptoJS.AES.decrypt(ciphertext, ElckerEryptoStr);
        return bytes.toString(CryptoJS.enc.Utf8);
    } else {
        return '';
    }

}

